package com.cwvs.cat.bean;

import org.json.JSONException;
import org.json.JSONObject;

public class FriendInfo {

	public String id;//5",
	public String username;//15371862380",
	public String passwd;//e3ceb5881a0a1fdaad01296d7554868d",
	public String nickname;//null,
	public String avatar;//null,
	public String gender;//0",
	public String sign;//null,
	public String location_x;//120.0000000000",
	public String location_y;//30.0000000000",
	public String location_time;//null,
	public String location_status;//0",
	public String modifed;//15-03-25 19:19:07"
	
	

	public void fromJson(JSONObject json){
		id = json.optString("id");
		username = json.optString("username");
		passwd = json.optString("passwd");
		nickname = json.optString("nickname");
		avatar = json.optString("avatar");
		gender = json.optString("gender");
		sign = json.optString("sign");
		location_x = json.optString("location_x");
		location_y = json.optString("location_y");
		location_time = json.optString("location_time");
		location_status = json.optString("location_status");
		modifed = json.optString("modifed");
	}
	public JSONObject toJson(){
		JSONObject json = new JSONObject();
		try {
			json.put("id", id);
			json.put("username", username);
			json.put("passwd", passwd);
			json.put("nickname", nickname);
			json.put("avatar", avatar);
			json.put("gender", gender);
			json.put("sign", sign);
			json.put("location_x", location_x);
			json.put("location_y", location_y);
			json.put("location_time", location_time);
			json.put("location_status", location_status);
			json.put("modifed", modifed);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return json;
	}
	public static FriendInfo createFromJson(JSONObject json) {
		FriendInfo user = new FriendInfo();
		user.fromJson(json);
		return user;
	}
}
